package com.zzyk.main.mapper;


import com.zzyk.main.model.pojo.Organization;
import com.zzyk.main.model.vo.OrganizationInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface SysOrganizationDao {
    //根据组织机构ID获取组织机构信息
    @Select("SELECT * FROM tb_organization WHERE `id` = #{id} and isDelete = 0 ")
    @ResultMap("organizationInfo")
    public OrganizationInfo getOrganization(@Param("id") int id);

    // 根据区域权限的字符串获取组织机构列表 他不认_parameter参数
    public List<Organization> getOrganizationsByIds(@Param("ids") String[] ids);

    // 同上 但是自关联的时候他来提示找不到参数 必须用_parameter 没法共用同一个语句
    public List<Organization> getOrganizations(String ids);

    @Select("SELECT * FROM tb_organization WHERE `name` = #{name} and isDelete = 0")
    @ResultMap("organizationInfo")
    public OrganizationInfo getOrganizationByName(@Param("name") String name);

    // 获取组织机构列表 模糊查询 精准查询定义了type
    public List<OrganizationInfo> getOrganizationList(Organization organization);

    // 新增组织机构
    public int addOrganization(Organization organization);

    // 更新组织机构
    public int updateOrganization(Organization organization);

    // 删除组织机构
    public int delOrganization(@Param("id") int id);

    List<OrganizationInfo> selectAreaById(@Param("area") String[] area);
    
    List<Organization> selectAllByParam(@Param("area") String[] area, @Param("param") String param);

}
